{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "617f6a82",
   "metadata": {
    "heading_collapsed": true
   },
   "source": [
    "### 数组创建"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "3a694eb7",
   "metadata": {
    "hidden": true
   },
   "outputs": [],
   "source": [
    "import numpy as np # shift + Enter"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "97ec46dc",
   "metadata": {
    "hidden": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1 2 3 4 5]\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "array([1, 2, 3, 4, 5])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 创建可以将python中list列表转换成NumPy数组\n",
    "l = [1,2,3,4,5]\n",
    "# NumPy数组\n",
    "nd1 = np.array(l)\n",
    "print(nd1)\n",
    "display(nd1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "5a1f63ea",
   "metadata": {
    "collapsed": true,
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0, 0, 0, 0],\n",
       "       [0, 0, 0, 0],\n",
       "       [0, 0, 0, 0]], dtype=int16)"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd2 = np.zeros(shape = (3,4),dtype = np.int16)\n",
    "nd2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "93415e4b",
   "metadata": {
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(array([1., 1., 1., 1., 1., 1., 1., 1., 1., 1.]),\n",
       " array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]),\n",
       " array([[2.718, 2.718, 2.718],\n",
       "        [2.718, 2.718, 2.718]]))"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "arr1 = np.ones(10)\n",
    "arr2 = np.zeros(10)\n",
    "arr3 = np.full(shape =[2,3],fill_value=2.718)\n",
    "arr1,arr2,arr3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "cec3b1ee",
   "metadata": {
    "hidden": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[3.1415 3.1415]]\n"
     ]
    }
   ],
   "source": [
    "arr4 = np.full(shape=[1,2],fill_value=3.1415)\n",
    "print(arr4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "13274b45",
   "metadata": {
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1, 1, 1, 1, 1],\n",
       "       [1, 1, 1, 1, 1],\n",
       "       [1, 1, 1, 1, 1]], dtype=int16)"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd3 = np.ones(shape = (3,5),dtype =np.)\n",
    "nd3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "6099e88b",
   "metadata": {
    "collapsed": true,
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([75, 95, 50,  2, 50, 78, 64, 71,  3, 23, 67, 29, 39, 99, 48, 17, 97,\n",
       "       35, 65, 55])"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd5 = np.random.randint(0,100,size = 20)\n",
    "nd5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "f23ff297",
   "metadata": {
    "collapsed": true,
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([90, 20, 88, 33, 80, 83, 46, 24, 32, 73, 24, 58, 81, 83, 81, 27, 63,\n",
       "       13, 13, 60])"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd5 = np.random.randint(0,100,size=20)\n",
    "nd5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "85d852ef",
   "metadata": {
    "collapsed": true,
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[7.70465717e-01, 9.95526754e-01, 8.91790722e-02, 9.02812395e-01,\n",
       "        9.76883898e-01],\n",
       "       [6.00353236e-01, 2.87682843e-02, 8.06963156e-04, 3.78728757e-01,\n",
       "        6.53165663e-02],\n",
       "       [6.37916140e-01, 1.01712548e-01, 9.50008597e-03, 8.15567084e-01,\n",
       "        8.50642847e-01]])"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd6 =np.random.rand(3,5)\n",
    "nd6"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "723e0678",
   "metadata": {
    "collapsed": true,
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-0.93492019,  0.5241902 ,  0.27045464,  0.04552736, -0.14309836],\n",
       "       [-0.42491752, -0.24724547,  0.21929001,  0.57832827,  0.0057025 ],\n",
       "       [-0.3714304 ,  0.09537795, -1.14650652, -1.67956826,  0.54459506]])"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd7 = np.random.randn(3,5)\n",
    "nd7"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "fb93f1f2",
   "metadata": {
    "hidden": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "170.2491302695825\n"
     ]
    }
   ],
   "source": [
    "nd8 = np.random.normal(loc = 175,scale=10)\n",
    "print(nd8)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "de79f7d8",
   "metadata": {
    "heading_collapsed": true
   },
   "source": [
    "# 基本操作"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d7ef2ca6",
   "metadata": {
    "hidden": true
   },
   "source": [
    "## 数组的创建"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "43496df1",
   "metadata": {
    "hidden": true
   },
   "source": [
    "## 查看数组的属性"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f17953ec",
   "metadata": {
    "heading_collapsed": true,
    "hidden": true
   },
   "source": [
    "## 文件的IO操作"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "15c784f5",
   "metadata": {
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 8, 72, 41,  8, 42],\n",
       "       [49, 83, 95, 64, 82],\n",
       "       [88, 40,  0, 37, 77]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "array([[ 1.11144743, -0.34790462,  0.83885783, -0.30825678, -1.17384465],\n",
       "       [ 1.85140916,  0.69555055,  1.80509279,  0.52525594,  0.23784458],\n",
       "       [ 1.28913741, -0.32774876,  0.1994076 , -0.01470359, -0.4180987 ]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import numpy as np\n",
    "nd1 = np.random.randint(0,100,size=(3,5))\n",
    "nd2 = np.random.randn(3,5)\n",
    "display(nd1,nd2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "d5e5048a",
   "metadata": {
    "hidden": true
   },
   "outputs": [],
   "source": [
    "np.save('./data',nd1) # 把一个数据存到文件中"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "e937a515",
   "metadata": {
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 8, 72, 41,  8, 42],\n",
       "       [49, 83, 95, 64, 82],\n",
       "       [88, 40,  0, 37, 77]])"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.load('./data.npy') #默认添加npy后缀"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "5e6faf40",
   "metadata": {
    "hidden": true
   },
   "outputs": [],
   "source": [
    "# 多个数组存到一个文件\n",
    "np.savez('./data.npz',aa = nd1, abc = nd2) #保存数据起名，aa abc 称为KEY自己起名"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "b4ece08c",
   "metadata": {
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<numpy.lib.npyio.NpzFile at 0x27ca09e02e0>"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data = np.load('./data.npz')\n",
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "386eab2c",
   "metadata": {
    "hidden": true
   },
   "outputs": [],
   "source": [
    "data['aa']  # 单引号\n",
    "data['abc']\n",
    "#data['www']\n",
    "np.savez_compressed('./data2.npz',x = nd1,y = nd2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "4f5b0680",
   "metadata": {
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 8, 72, 41,  8, 42],\n",
       "       [49, 83, 95, 64, 82],\n",
       "       [88, 40,  0, 37, 77]])"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.load('./data2.npz')['x']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "227a8348",
   "metadata": {
    "hidden": true
   },
   "outputs": [],
   "source": [
    "np.savetxt(fname = './data.txt',#文件名\n",
    "          X = nd1, #数据\n",
    "          fmt = '%0.2f', #格式\n",
    "          delimiter = ',')#分隔箱"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "3bc1c93d",
   "metadata": {
    "hidden": true
   },
   "outputs": [],
   "source": [
    "np.savetxt(fname = './data.cvs',#文件名\n",
    "          X = nd1, #数据\n",
    "          fmt = '%d', #格式\n",
    "          delimiter = ';')#分隔箱"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "0d3b8129",
   "metadata": {
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 8., 72., 41.,  8., 42.],\n",
       "       [49., 83., 95., 64., 82.],\n",
       "       [88., 40.,  0., 37., 77.]])"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.loadtxt('./data.cvs',delimiter=';')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "0f2e2fe4",
   "metadata": {
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 8., 72., 41.,  8., 42.],\n",
       "       [49., 83., 95., 64., 82.],\n",
       "       [88., 40.,  0., 37., 77.]])"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.loadtxt('./data.txt',delimiter=',')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3c8fb598",
   "metadata": {
    "heading_collapsed": true
   },
   "source": [
    "# 数据类型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "b386cf3a",
   "metadata": {
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([2, 4, 7], dtype=int8)"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#int8,int16,int32,int64,uint8无符号\n",
    "#float16,float32,float64\n",
    "#str字符串类型\n",
    "#int8表示2**8个数字，256个，-128 - 127有箱号\n",
    "#uint8表示256个数字，无符号，表明只有正数：0 - 255\n",
    "np.array([2,4,7],dtype=np.int8)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "01f66b36",
   "metadata": {
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([253, 249, 255, 108,   0,   0], dtype=uint8)"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.array([-3,-7,255,108,0,256],dtype=np.uint8)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "e5fab53b",
   "metadata": {
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 2, 37, 30, 57, 70, 13, 43, 57, 82, 34], dtype=int64)"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.random.randint(0,100,size=10,dtype='int64')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "4b35b611",
   "metadata": {
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0.86699057, 0.10542844],\n",
       "       [0.55826924, 0.32106036],\n",
       "       [0.83057026, 0.49292136],\n",
       "       [0.90722209, 0.91823934],\n",
       "       [0.3592559 , 0.09714627],\n",
       "       [0.11540485, 0.94552739],\n",
       "       [0.18696296, 0.17386132],\n",
       "       [0.0526518 , 0.03681307],\n",
       "       [0.66241826, 0.5284991 ],\n",
       "       [0.83574025, 0.05556248]])"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd = np.random.rand(10,2)\n",
    "nd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "b135fc72",
   "metadata": {
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "dtype('float64')"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd.dtype"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "f19b1a83",
   "metadata": {
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0.867  , 0.1054 ],\n",
       "       [0.558  , 0.321  ],\n",
       "       [0.8306 , 0.493  ],\n",
       "       [0.907  , 0.9185 ],\n",
       "       [0.3594 , 0.09717],\n",
       "       [0.1154 , 0.9453 ],\n",
       "       [0.187  , 0.1738 ],\n",
       "       [0.05264, 0.0368 ],\n",
       "       [0.6626 , 0.5283 ],\n",
       "       [0.836  , 0.05557]], dtype=float16)"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.asanyarray(nd,dtype = 'float16')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "27c79b23",
   "metadata": {
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0.867  , 0.1054 ],\n",
       "       [0.558  , 0.321  ],\n",
       "       [0.8306 , 0.493  ],\n",
       "       [0.907  , 0.9185 ],\n",
       "       [0.3594 , 0.09717],\n",
       "       [0.1154 , 0.9453 ],\n",
       "       [0.187  , 0.1738 ],\n",
       "       [0.05264, 0.0368 ],\n",
       "       [0.6626 , 0.5283 ],\n",
       "       [0.836  , 0.05557]], dtype=float16)"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd.astype(dtype=np.float16)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "f34a5667",
   "metadata": {
    "hidden": true
   },
   "outputs": [],
   "source": [
    "nd = np.random.rand(1000,3) #默认数据类型是float64\n",
    "np.save('./data1',nd)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "c7f5a4b2",
   "metadata": {
    "hidden": true
   },
   "outputs": [],
   "source": [
    "np.save('./data2',nd.astype('float16'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "69d28263",
   "metadata": {
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'], dtype='<U1')"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd2 = np.array(list('abcdefghi'))\n",
    "nd2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "13d3929b",
   "metadata": {
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "dtype('<U1')"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd2.dtype"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f6604ba6",
   "metadata": {
    "heading_collapsed": true
   },
   "source": [
    "# 数组运算"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6c19b70c",
   "metadata": {
    "heading_collapsed": true
   },
   "source": [
    "# 索引、切片和迭代"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "414dbe28",
   "metadata": {
    "heading_collapsed": true,
    "hidden": true
   },
   "source": [
    "## 基本索引和切片"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "67e94ea5",
   "metadata": {
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([17, 12, 18,  1,  5, 16,  7,  3, 23, 17])"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a  = np.random.randint(0,30,size =10)\n",
    "a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "b4824b8e",
   "metadata": {
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([12, 16,  3])"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a[3]\n",
    "a[[1,5,7]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "b4376ba6",
   "metadata": {
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([17, 12, 18])"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a[0:3]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c4f5fc8a",
   "metadata": {
    "hidden": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b15466b8",
   "metadata": {
    "hidden": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "e678edb6",
   "metadata": {
    "heading_collapsed": true
   },
   "source": [
    "# numpy的形状操作"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "05a7ad42",
   "metadata": {
    "heading_collapsed": true,
    "hidden": true
   },
   "source": [
    "## 数组变形"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "1eeccac3",
   "metadata": {
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1, 2, 8, 3, 6],\n",
       "       [6, 1, 4, 9, 5],\n",
       "       [3, 6, 6, 4, 8]])"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "\n",
    "a = np.random.randint(0,10,size = (3,5))\n",
    "a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "57b0c3da",
   "metadata": {
    "collapsed": true,
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1, 2, 8],\n",
       "       [3, 6, 6],\n",
       "       [1, 4, 9],\n",
       "       [5, 3, 6],\n",
       "       [6, 4, 8]])"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a.reshape(5,3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "85964c7d",
   "metadata": {
    "collapsed": true,
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1],\n",
       "       [2],\n",
       "       [8],\n",
       "       [3],\n",
       "       [6],\n",
       "       [6],\n",
       "       [1],\n",
       "       [4],\n",
       "       [9],\n",
       "       [5],\n",
       "       [3],\n",
       "       [6],\n",
       "       [6],\n",
       "       [4],\n",
       "       [8]])"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a.reshape(15,1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "9ade2cb4",
   "metadata": {
    "collapsed": true,
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[[1]],\n",
       "\n",
       "       [[2]],\n",
       "\n",
       "       [[8]],\n",
       "\n",
       "       [[3]],\n",
       "\n",
       "       [[6]],\n",
       "\n",
       "       [[6]],\n",
       "\n",
       "       [[1]],\n",
       "\n",
       "       [[4]],\n",
       "\n",
       "       [[9]],\n",
       "\n",
       "       [[5]],\n",
       "\n",
       "       [[3]],\n",
       "\n",
       "       [[6]],\n",
       "\n",
       "       [[6]],\n",
       "\n",
       "       [[4]],\n",
       "\n",
       "       [[8]]])"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a.reshape(15,1,1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "f166cc98",
   "metadata": {
    "collapsed": true,
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1, 2, 8],\n",
       "       [3, 6, 6],\n",
       "       [1, 4, 9],\n",
       "       [5, 3, 6],\n",
       "       [6, 4, 8]])"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a.reshape(-1,3)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "54fe7b95",
   "metadata": {
    "heading_collapsed": true,
    "hidden": true
   },
   "source": [
    "## 数组转置"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "d0ab08c8",
   "metadata": {
    "collapsed": true,
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1, 6, 3],\n",
       "       [2, 1, 6],\n",
       "       [8, 4, 6],\n",
       "       [3, 9, 4],\n",
       "       [6, 5, 8]])"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a.T #矩阵"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "02a5f7ec",
   "metadata": {
    "collapsed": true,
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1, 6, 3],\n",
       "       [2, 1, 6],\n",
       "       [8, 4, 6],\n",
       "       [3, 9, 4],\n",
       "       [6, 5, 8]])"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.transpose(a,(1,0))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "70c8b708",
   "metadata": {
    "collapsed": true,
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[[2, 4, 2, 5, 8, 5, 1],\n",
       "        [3, 5, 6, 9, 7, 8, 9],\n",
       "        [0, 3, 9, 8, 9, 7, 2],\n",
       "        [2, 8, 9, 8, 8, 5, 8],\n",
       "        [4, 1, 2, 0, 7, 5, 6]],\n",
       "\n",
       "       [[4, 2, 3, 0, 2, 9, 4],\n",
       "        [2, 4, 9, 3, 0, 2, 6],\n",
       "        [0, 7, 1, 4, 7, 8, 9],\n",
       "        [3, 3, 9, 2, 7, 4, 8],\n",
       "        [6, 5, 3, 3, 2, 7, 1]],\n",
       "\n",
       "       [[0, 3, 7, 1, 1, 9, 0],\n",
       "        [7, 5, 4, 0, 6, 7, 8],\n",
       "        [3, 5, 3, 3, 5, 5, 7],\n",
       "        [8, 5, 6, 2, 4, 8, 5],\n",
       "        [0, 8, 0, 7, 4, 7, 6]]])"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "b = np.random.randint(0,10,size=(3,5,7))\n",
    "b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "51cb9b93",
   "metadata": {
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(7, 5, 3)"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c = np.transpose(b,(2,1,0))\n",
    "c.shape"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f97908e5",
   "metadata": {
    "heading_collapsed": true,
    "hidden": true
   },
   "source": [
    "## 数据堆叠合并"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "37bd45e2",
   "metadata": {
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[4, 2, 3, 5, 9],\n",
       "       [7, 5, 3, 0, 6],\n",
       "       [4, 8, 9, 1, 9]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "array([[8, 8, 6, 2, 0],\n",
       "       [7, 3, 7, 4, 3],\n",
       "       [5, 4, 6, 0, 4]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "nd1 = np.random.randint(0,10,size=(3,5))\n",
    "nd2 = np.random.randint(0,10,size=(3,5))\n",
    "display(nd1,nd2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "432903e0",
   "metadata": {
    "collapsed": true,
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[4, 2, 3, 5, 9],\n",
       "       [7, 5, 3, 0, 6],\n",
       "       [4, 8, 9, 1, 9],\n",
       "       [8, 8, 6, 2, 0],\n",
       "       [7, 3, 7, 4, 3],\n",
       "       [5, 4, 6, 0, 4]])"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.concatenate([nd1,nd2])#默认合并行增加"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "3cd48d21",
   "metadata": {
    "collapsed": true,
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[4, 2, 3, 5, 9, 8, 8, 6, 2, 0],\n",
       "       [7, 5, 3, 0, 6, 7, 3, 7, 4, 3],\n",
       "       [4, 8, 9, 1, 9, 5, 4, 6, 0, 4]])"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 修改axis参数调整数据合并方向\n",
    "np.concatenate([nd1,nd2],axis=1) #axis轴，方向0=行，1=列"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "286881b3",
   "metadata": {
    "collapsed": true,
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[4, 2, 3, 5, 9, 8, 8, 6, 2, 0],\n",
       "       [7, 5, 3, 0, 6, 7, 3, 7, 4, 3],\n",
       "       [4, 8, 9, 1, 9, 5, 4, 6, 0, 4]])"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.hstack((nd1,nd2))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "38e50780",
   "metadata": {
    "collapsed": true,
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[4, 2, 3, 5, 9],\n",
       "       [7, 5, 3, 0, 6],\n",
       "       [4, 8, 9, 1, 9],\n",
       "       [8, 8, 6, 2, 0],\n",
       "       [7, 3, 7, 4, 3],\n",
       "       [5, 4, 6, 0, 4],\n",
       "       [8, 8, 6, 2, 0],\n",
       "       [7, 3, 7, 4, 3],\n",
       "       [5, 4, 6, 0, 4],\n",
       "       [8, 8, 6, 2, 0],\n",
       "       [7, 3, 7, 4, 3],\n",
       "       [5, 4, 6, 0, 4],\n",
       "       [4, 2, 3, 5, 9],\n",
       "       [7, 5, 3, 0, 6],\n",
       "       [4, 8, 9, 1, 9]])"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.vstack((nd1,nd2,nd2,nd2,nd1))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b7b38fb3",
   "metadata": {
    "hidden": true
   },
   "source": [
    "## 数组拆分"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "924587a6",
   "metadata": {
    "collapsed": true,
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[48, 35, 79, 54, 82,  7, 27, 61, 64, 78],\n",
       "       [58, 88, 61, 34, 30, 48,  1, 14, 85, 78],\n",
       "       [83, 86, 40, 47, 86, 74, 29, 44,  2, 33],\n",
       "       [46, 75, 40, 70, 93,  7, 38, 40, 44, 29],\n",
       "       [70, 57, 43, 58, 74, 67,  8, 88, 71, 47],\n",
       "       [34,  5, 19, 92, 51, 26, 88, 97, 70,  2],\n",
       "       [87,  2, 84, 95, 54, 65, 54,  1, 81, 96],\n",
       "       [81, 97, 57, 86, 24, 59, 77, 56, 54, 44],\n",
       "       [29, 42, 59, 29, 56, 46, 81, 87, 86, 71],\n",
       "       [52, 10,  5, 62, 60, 86, 57, 70, 19, 33],\n",
       "       [71, 55, 66, 41, 20, 76, 81,  0, 89, 80],\n",
       "       [27, 48, 25, 21, 56, 61, 66, 47,  9, 57],\n",
       "       [30, 11, 83, 82, 64, 89, 75, 31, 21, 41],\n",
       "       [74, 15, 87, 19,  0, 28, 39, 42, 61, 46],\n",
       "       [41, 77, 65, 14, 65, 84, 92, 10, 82, 19]])"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a = np.random.randint(0,100,size=(15,10))\n",
    "a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "e022cec5",
   "metadata": {
    "collapsed": true,
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[array([[48, 35, 79, 54, 82,  7, 27, 61, 64, 78],\n",
       "        [58, 88, 61, 34, 30, 48,  1, 14, 85, 78],\n",
       "        [83, 86, 40, 47, 86, 74, 29, 44,  2, 33]]),\n",
       " array([[46, 75, 40, 70, 93,  7, 38, 40, 44, 29],\n",
       "        [70, 57, 43, 58, 74, 67,  8, 88, 71, 47],\n",
       "        [34,  5, 19, 92, 51, 26, 88, 97, 70,  2]]),\n",
       " array([[87,  2, 84, 95, 54, 65, 54,  1, 81, 96],\n",
       "        [81, 97, 57, 86, 24, 59, 77, 56, 54, 44],\n",
       "        [29, 42, 59, 29, 56, 46, 81, 87, 86, 71]]),\n",
       " array([[52, 10,  5, 62, 60, 86, 57, 70, 19, 33],\n",
       "        [71, 55, 66, 41, 20, 76, 81,  0, 89, 80],\n",
       "        [27, 48, 25, 21, 56, 61, 66, 47,  9, 57]]),\n",
       " array([[30, 11, 83, 82, 64, 89, 75, 31, 21, 41],\n",
       "        [74, 15, 87, 19,  0, 28, 39, 42, 61, 46],\n",
       "        [41, 77, 65, 14, 65, 84, 92, 10, 82, 19]])]"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.split(a,indices_or_sections=5) #给数字，表示平均分成多少份"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "5c73e5d7",
   "metadata": {
    "collapsed": true,
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[array([[48, 35, 79, 54, 82],\n",
       "        [58, 88, 61, 34, 30],\n",
       "        [83, 86, 40, 47, 86],\n",
       "        [46, 75, 40, 70, 93],\n",
       "        [70, 57, 43, 58, 74],\n",
       "        [34,  5, 19, 92, 51],\n",
       "        [87,  2, 84, 95, 54],\n",
       "        [81, 97, 57, 86, 24],\n",
       "        [29, 42, 59, 29, 56],\n",
       "        [52, 10,  5, 62, 60],\n",
       "        [71, 55, 66, 41, 20],\n",
       "        [27, 48, 25, 21, 56],\n",
       "        [30, 11, 83, 82, 64],\n",
       "        [74, 15, 87, 19,  0],\n",
       "        [41, 77, 65, 14, 65]]),\n",
       " array([[ 7, 27, 61, 64, 78],\n",
       "        [48,  1, 14, 85, 78],\n",
       "        [74, 29, 44,  2, 33],\n",
       "        [ 7, 38, 40, 44, 29],\n",
       "        [67,  8, 88, 71, 47],\n",
       "        [26, 88, 97, 70,  2],\n",
       "        [65, 54,  1, 81, 96],\n",
       "        [59, 77, 56, 54, 44],\n",
       "        [46, 81, 87, 86, 71],\n",
       "        [86, 57, 70, 19, 33],\n",
       "        [76, 81,  0, 89, 80],\n",
       "        [61, 66, 47,  9, 57],\n",
       "        [89, 75, 31, 21, 41],\n",
       "        [28, 39, 42, 61, 46],\n",
       "        [84, 92, 10, 82, 19]])]"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.split(a,indices_or_sections=2,axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "a0c428bf",
   "metadata": {
    "collapsed": true,
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[array([[48, 35, 79, 54, 82,  7, 27, 61, 64, 78]]),\n",
       " array([[58, 88, 61, 34, 30, 48,  1, 14, 85, 78],\n",
       "        [83, 86, 40, 47, 86, 74, 29, 44,  2, 33],\n",
       "        [46, 75, 40, 70, 93,  7, 38, 40, 44, 29],\n",
       "        [70, 57, 43, 58, 74, 67,  8, 88, 71, 47]]),\n",
       " array([[34,  5, 19, 92, 51, 26, 88, 97, 70,  2],\n",
       "        [87,  2, 84, 95, 54, 65, 54,  1, 81, 96],\n",
       "        [81, 97, 57, 86, 24, 59, 77, 56, 54, 44],\n",
       "        [29, 42, 59, 29, 56, 46, 81, 87, 86, 71]]),\n",
       " array([[52, 10,  5, 62, 60, 86, 57, 70, 19, 33],\n",
       "        [71, 55, 66, 41, 20, 76, 81,  0, 89, 80],\n",
       "        [27, 48, 25, 21, 56, 61, 66, 47,  9, 57],\n",
       "        [30, 11, 83, 82, 64, 89, 75, 31, 21, 41],\n",
       "        [74, 15, 87, 19,  0, 28, 39, 42, 61, 46],\n",
       "        [41, 77, 65, 14, 65, 84, 92, 10, 82, 19]])]"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#参数给列表，根据列表中的索引，进行切片\n",
    "np.split(a,indices_or_sections=[1,5,9])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "50d4c4c6",
   "metadata": {
    "collapsed": true,
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[array([[48, 35, 79, 54, 82],\n",
       "        [58, 88, 61, 34, 30],\n",
       "        [83, 86, 40, 47, 86],\n",
       "        [46, 75, 40, 70, 93],\n",
       "        [70, 57, 43, 58, 74],\n",
       "        [34,  5, 19, 92, 51],\n",
       "        [87,  2, 84, 95, 54],\n",
       "        [81, 97, 57, 86, 24],\n",
       "        [29, 42, 59, 29, 56],\n",
       "        [52, 10,  5, 62, 60],\n",
       "        [71, 55, 66, 41, 20],\n",
       "        [27, 48, 25, 21, 56],\n",
       "        [30, 11, 83, 82, 64],\n",
       "        [74, 15, 87, 19,  0],\n",
       "        [41, 77, 65, 14, 65]]),\n",
       " array([[ 7, 27, 61, 64, 78],\n",
       "        [48,  1, 14, 85, 78],\n",
       "        [74, 29, 44,  2, 33],\n",
       "        [ 7, 38, 40, 44, 29],\n",
       "        [67,  8, 88, 71, 47],\n",
       "        [26, 88, 97, 70,  2],\n",
       "        [65, 54,  1, 81, 96],\n",
       "        [59, 77, 56, 54, 44],\n",
       "        [46, 81, 87, 86, 71],\n",
       "        [86, 57, 70, 19, 33],\n",
       "        [76, 81,  0, 89, 80],\n",
       "        [61, 66, 47,  9, 57],\n",
       "        [89, 75, 31, 21, 41],\n",
       "        [28, 39, 42, 61, 46],\n",
       "        [84, 92, 10, 82, 19]])]"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.hsplit(a,indices_or_sections=2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "fa85f18b",
   "metadata": {
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[array([[48, 35, 79, 54, 82,  7, 27, 61, 64, 78],\n",
       "        [58, 88, 61, 34, 30, 48,  1, 14, 85, 78],\n",
       "        [83, 86, 40, 47, 86, 74, 29, 44,  2, 33]]),\n",
       " array([[46, 75, 40, 70, 93,  7, 38, 40, 44, 29],\n",
       "        [70, 57, 43, 58, 74, 67,  8, 88, 71, 47],\n",
       "        [34,  5, 19, 92, 51, 26, 88, 97, 70,  2],\n",
       "        [87,  2, 84, 95, 54, 65, 54,  1, 81, 96]]),\n",
       " array([[81, 97, 57, 86, 24, 59, 77, 56, 54, 44],\n",
       "        [29, 42, 59, 29, 56, 46, 81, 87, 86, 71],\n",
       "        [52, 10,  5, 62, 60, 86, 57, 70, 19, 33],\n",
       "        [71, 55, 66, 41, 20, 76, 81,  0, 89, 80]]),\n",
       " array([[27, 48, 25, 21, 56, 61, 66, 47,  9, 57],\n",
       "        [30, 11, 83, 82, 64, 89, 75, 31, 21, 41],\n",
       "        [74, 15, 87, 19,  0, 28, 39, 42, 61, 46],\n",
       "        [41, 77, 65, 14, 65, 84, 92, 10, 82, 19]])]"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.vsplit(a,indices_or_sections=[3,7,11])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b699b43c",
   "metadata": {
    "hidden": true
   },
   "source": [
    "## 广播机制"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "d0ad0d8b",
   "metadata": {
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0, 0, 0],\n",
       "       [1, 1, 1],\n",
       "       [2, 2, 2],\n",
       "       [3, 3, 3]])"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "arr1 = np.array([0,1,2,3]*3)\n",
    "arr1.sort() # 排序，从小到大\n",
    "arr1 = arr1.reshape(4,3)\n",
    "arr1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "aeb8e207",
   "metadata": {
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0, 0, 0],\n",
       "       [1, 1, 1],\n",
       "       [2, 2, 2],\n",
       "       [3, 3, 3]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "array([1, 2, 3])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "arr2 = np.array([1,2,3])\n",
    "display(arr1,arr2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "483db265",
   "metadata": {
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1, 2, 3],\n",
       "       [2, 3, 4],\n",
       "       [3, 4, 5],\n",
       "       [4, 5, 6]])"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#行不够，广播行\n",
    "arr1 + arr2 #arr2和arr1中每一行，进行相加：广播机制"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "9afc1724",
   "metadata": {
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1],\n",
       "       [2],\n",
       "       [3],\n",
       "       [4]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "arr3 = np.array([[1],[2],[3],[4]])\n",
    "display(arr3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "56515fb4",
   "metadata": {
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1, 1, 1],\n",
       "       [3, 3, 3],\n",
       "       [5, 5, 5],\n",
       "       [7, 7, 7]])"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "arr1 = np.sort(np.array([0,1,2,3]*3)).reshape(4,3) # shape(4,3)\n",
    "arr2 = np.array([[1],[2],[3],[4]]) # shape(4,1)\n",
    "arr3 = arr1 + arr2 # arr2 进行广播复制3份 shape(4,3)\n",
    "arr3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "16f17881",
   "metadata": {
    "hidden": true
   },
   "outputs": [],
   "source": [
    "arr1 = np.array([0,1,2,3,4,5,6,7]*3).reshape(3,4,2) #shape(3,4,2)\n",
    "arr2 = np.array([0,1,2,3,4,5,6,7]).reshape(4,2) #shape(4,2)\n",
    "arr3 = arr1 + arr2 # arr2数组在0维上复制3份 shape(3,4,2)\n",
    "arr3\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e569ac66",
   "metadata": {
    "heading_collapsed": true
   },
   "source": [
    "# 通用函数"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1cca4f26",
   "metadata": {
    "hidden": true
   },
   "source": [
    "## 元素级数字函数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "8660f68b",
   "metadata": {
    "collapsed": true,
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 2.,  4.,  8.,  9., 16., 16.])"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "arr1 = np.array([1,4,8,9,16,25])\n",
    "arr1 = np.sqrt(arr1) # 开平方\n",
    "arr1\n",
    "arr1 = np.square(arr1) # 平方\n",
    "arr1\n",
    "arr1 = np.clip(arr1,2,16) # 输出 array([ 2, 4, 8, 9, 16, 16])\n",
    "arr1"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "339f24fc",
   "metadata": {
    "hidden": true
   },
   "source": [
    "## 数学统计和计算"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "623bdc63",
   "metadata": {
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[87, 50, 59, 96, 75],\n",
       "       [69, 68, 96, 56, 62],\n",
       "       [27, 36,  0,  9, 68]])"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "a = np.random.randint(0,100,size=(3,5))\n",
    "a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "5b02315f",
   "metadata": {
    "collapsed": true,
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a.min()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "7a7e2eda",
   "metadata": {
    "collapsed": true,
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([87, 68, 96, 96, 75])"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a.max(axis=0) #axis轴，方向。axis=0行，axis=1列"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "72e7cae9",
   "metadata": {
    "collapsed": true,
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([96, 96, 68])"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a.max(axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "11d6ac87",
   "metadata": {
    "collapsed": true,
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "57.2"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a.mean() #平均数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "9ed8a1d8",
   "metadata": {
    "collapsed": true,
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "62.0"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.median(a) #中位数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "1c01b706",
   "metadata": {
    "collapsed": true,
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "858"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a.sum() #求和"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "5d3ab4eb",
   "metadata": {
    "collapsed": true,
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "27.83810338367181"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a.std() #标准差"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "cecc9bdd",
   "metadata": {
    "collapsed": true,
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "774.9599999999999"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a.var() #方差，数据内部波动"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "27fed200",
   "metadata": {
    "collapsed": true,
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 87, 137, 196, 292, 367, 436, 504, 600, 656, 718, 745, 781, 781,\n",
       "       790, 858], dtype=int32)"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a.cumsum() #累加和"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "8f7ba981",
   "metadata": {
    "collapsed": true,
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([         87,        4350,      256650,    24638400,  1847880000,\n",
       "       -1345298880, -1286010624,  1097031680,  1304231936,  -741998592,\n",
       "        1440874496,   331874304,           0,           0,           0],\n",
       "      dtype=int32)"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a.cumprod() #累乘和"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "4a872521",
   "metadata": {
    "collapsed": true,
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "12"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a.argmin() #最小值索引"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "cec57aa3",
   "metadata": {
    "collapsed": true,
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a.argmax() #最大值索引"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "8cf17779",
   "metadata": {
    "collapsed": true,
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0, 0],\n",
       "       [0, 2],\n",
       "       [0, 3],\n",
       "       [0, 4],\n",
       "       [1, 0],\n",
       "       [1, 1],\n",
       "       [1, 2],\n",
       "       [1, 3],\n",
       "       [1, 4],\n",
       "       [2, 4]], dtype=int64)"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "index = np.argwhere(a>50) #返回就是符合条件的索引\n",
    "index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "7a6d8648",
   "metadata": {
    "collapsed": true,
    "hidden": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "87\n",
      "59\n",
      "96\n",
      "75\n",
      "69\n",
      "68\n",
      "96\n",
      "56\n",
      "62\n",
      "68\n"
     ]
    }
   ],
   "source": [
    "for i,j in index:\n",
    "    print(a[i,j])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "501f0ea7",
   "metadata": {
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 363.3 , -167.6 ,  -40.75],\n",
       "       [-167.6 ,  235.2 , -199.25],\n",
       "       [ -40.75, -199.25,  702.5 ]])"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# cov协方差（属性之间进行计算），方差概念类似（数据内部，属性内部计算）\n",
    "np.cov(a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "18944719",
   "metadata": {
    "hidden": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 1.        , -0.57335375, -0.08066251],\n",
       "       [-0.57335375,  1.        , -0.49018104],\n",
       "       [-0.08066251, -0.49018104,  1.        ]])"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.corrcoef(a)  #相关系数"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f56ffe57",
   "metadata": {},
   "source": [
    "# 线性代数"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2828cbd3",
   "metadata": {},
   "source": [
    "# 作业"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "39f44a95",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[95, 81, 47],\n",
       "       [10, 51, 80],\n",
       "       [56, 33, 53],\n",
       "       [36, 74, 88],\n",
       "       [39, 79, 63],\n",
       "       [97, 63, 47],\n",
       "       [66, 25, 94],\n",
       "       [29, 29, 64],\n",
       "       [33, 25, 23],\n",
       "       [78, 35, 70],\n",
       "       [87, 37, 57],\n",
       "       [99, 18, 90],\n",
       "       [60, 69, 62],\n",
       "       [90, 76, 14],\n",
       "       [29,  2, 53],\n",
       "       [20, 36,  1],\n",
       "       [23, 42, 33],\n",
       "       [ 1, 18, 94],\n",
       "       [ 7, 53, 92],\n",
       "       [ 7, 77, 35],\n",
       "       [77, 57, 54],\n",
       "       [57, 63, 26],\n",
       "       [52, 35, 47],\n",
       "       [55, 67, 96],\n",
       "       [84, 80,  2],\n",
       "       [ 3, 63, 96],\n",
       "       [97, 72, 85],\n",
       "       [84, 57,  5],\n",
       "       [42, 52, 19],\n",
       "       [ 3,  8, 41],\n",
       "       [84, 32, 39],\n",
       "       [18, 56, 78],\n",
       "       [52, 32, 15],\n",
       "       [76, 34, 65],\n",
       "       [13, 83, 17],\n",
       "       [10, 76, 94],\n",
       "       [67, 54, 19],\n",
       "       [49, 32, 61],\n",
       "       [ 5, 87, 10],\n",
       "       [93, 83, 30],\n",
       "       [31, 17, 88],\n",
       "       [44, 55, 28],\n",
       "       [81,  0, 72],\n",
       "       [49, 78, 33],\n",
       "       [64, 38, 73],\n",
       "       [88, 79, 32],\n",
       "       [55, 76, 97],\n",
       "       [11, 88, 10],\n",
       "       [35, 38, 49],\n",
       "       [86, 47, 12]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "array([[12, 77, 38],\n",
       "       [ 8, 42, 61],\n",
       "       [34, 16, 82],\n",
       "       [42, 98,  0],\n",
       "       [ 4, 11, 77],\n",
       "       [20, 72, 57],\n",
       "       [30, 13, 53],\n",
       "       [30,  1, 74],\n",
       "       [73, 85, 36],\n",
       "       [45, 85, 32],\n",
       "       [64, 75, 88],\n",
       "       [51, 63, 26],\n",
       "       [88, 55, 70],\n",
       "       [60, 86, 66],\n",
       "       [23, 57,  6],\n",
       "       [76,  3, 36],\n",
       "       [52, 19, 54],\n",
       "       [80, 50, 42],\n",
       "       [ 5, 57, 47],\n",
       "       [76, 25,  4],\n",
       "       [ 1, 99, 49],\n",
       "       [ 7, 44, 70],\n",
       "       [53, 83, 78],\n",
       "       [59, 59, 23],\n",
       "       [17, 29, 99],\n",
       "       [47, 61,  2],\n",
       "       [ 4, 74, 28],\n",
       "       [57,  8, 88],\n",
       "       [76, 42, 46],\n",
       "       [74, 96, 34],\n",
       "       [29, 31, 80],\n",
       "       [58, 82, 91],\n",
       "       [67, 99, 78],\n",
       "       [34,  7, 12],\n",
       "       [61, 36, 61],\n",
       "       [19, 70,  3],\n",
       "       [75, 91, 41],\n",
       "       [20, 22, 92],\n",
       "       [61,  3, 19],\n",
       "       [62, 87, 30],\n",
       "       [66, 82, 86],\n",
       "       [28, 53, 76],\n",
       "       [16, 54, 48],\n",
       "       [83, 52, 20],\n",
       "       [43,  4, 97],\n",
       "       [14,  1, 97],\n",
       "       [90, 77,  8],\n",
       "       [56, 95,  0],\n",
       "       [55, 30, 14],\n",
       "       [54, 89, 82]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "array([[44, 56, 26],\n",
       "       [ 3, 40, 44],\n",
       "       [76, 24, 61],\n",
       "       [80, 77, 74],\n",
       "       [60, 64, 61],\n",
       "       [28, 93, 53],\n",
       "       [80, 60, 36],\n",
       "       [46, 92, 48],\n",
       "       [99,  4, 51],\n",
       "       [83, 33, 40],\n",
       "       [14, 35,  8],\n",
       "       [84, 74, 76],\n",
       "       [54, 59, 15],\n",
       "       [52, 58, 87],\n",
       "       [39, 32, 36],\n",
       "       [22, 71, 66],\n",
       "       [43, 26, 67],\n",
       "       [ 0, 46, 99],\n",
       "       [38, 75, 45],\n",
       "       [20, 85, 42],\n",
       "       [87, 84, 73],\n",
       "       [15, 76, 12],\n",
       "       [42, 14, 68],\n",
       "       [96, 82, 55],\n",
       "       [98, 95, 69],\n",
       "       [ 8, 37, 91],\n",
       "       [82, 35, 24],\n",
       "       [ 8, 99, 54],\n",
       "       [44, 93, 52],\n",
       "       [89, 74, 39],\n",
       "       [88, 30, 97],\n",
       "       [18, 25, 40],\n",
       "       [90, 94,  0],\n",
       "       [93, 48, 64],\n",
       "       [61, 86, 25],\n",
       "       [12, 69, 71],\n",
       "       [38,  2, 63],\n",
       "       [ 3, 30, 61],\n",
       "       [74, 38, 62],\n",
       "       [34, 63, 81],\n",
       "       [36, 78, 47],\n",
       "       [87, 30, 99],\n",
       "       [87, 58, 95],\n",
       "       [57, 24, 63],\n",
       "       [51, 90, 60],\n",
       "       [ 4, 62, 56],\n",
       "       [80,  3,  3],\n",
       "       [28, 54, 68],\n",
       "       [ 5, 48, 75],\n",
       "       [ 0, 22, 71]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "array([[ 0, 19, 32],\n",
       "       [ 1, 91, 55],\n",
       "       [60, 16, 42],\n",
       "       [40, 85, 60],\n",
       "       [34, 53, 40],\n",
       "       [16,  4, 38],\n",
       "       [93, 66, 12],\n",
       "       [35, 79, 52],\n",
       "       [52, 15, 60],\n",
       "       [91, 20, 51],\n",
       "       [37, 68, 59],\n",
       "       [88, 79, 85],\n",
       "       [66, 63, 11],\n",
       "       [57, 94, 37],\n",
       "       [ 1,  0, 20],\n",
       "       [24, 53, 92],\n",
       "       [ 0, 68, 86],\n",
       "       [62, 13, 23],\n",
       "       [15, 87, 22],\n",
       "       [47, 33, 10],\n",
       "       [34, 15, 85],\n",
       "       [76,  2, 54],\n",
       "       [59, 61, 44],\n",
       "       [ 5, 19, 82],\n",
       "       [ 0,  1,  2],\n",
       "       [10, 13, 87],\n",
       "       [ 4, 88, 14],\n",
       "       [10, 21, 70],\n",
       "       [ 8, 26, 25],\n",
       "       [24, 52, 35],\n",
       "       [67, 21, 76],\n",
       "       [57, 36, 67],\n",
       "       [55, 89, 63],\n",
       "       [20, 72, 92],\n",
       "       [21, 82, 66],\n",
       "       [62, 94,  6],\n",
       "       [ 6,  8, 40],\n",
       "       [37, 62, 76],\n",
       "       [19, 32, 95],\n",
       "       [96, 99, 29],\n",
       "       [67, 68, 84],\n",
       "       [13, 12, 67],\n",
       "       [14, 15, 82],\n",
       "       [80,  9, 42],\n",
       "       [46, 95, 32],\n",
       "       [11, 75,  1],\n",
       "       [40, 70, 22],\n",
       "       [68, 95, 26],\n",
       "       [41, 21, 82],\n",
       "       [47, 55, 25]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "array([[ 9, 14, 63],\n",
       "       [27, 64, 73],\n",
       "       [79, 81, 25],\n",
       "       [35, 92, 95],\n",
       "       [21, 78,  8],\n",
       "       [20, 48, 69],\n",
       "       [64, 95, 80],\n",
       "       [94, 62, 80],\n",
       "       [19, 67, 15],\n",
       "       [57, 39, 40],\n",
       "       [73, 72, 79],\n",
       "       [96, 31, 10],\n",
       "       [59,  1, 51],\n",
       "       [47, 90, 98],\n",
       "       [29, 50, 99],\n",
       "       [46, 49, 34],\n",
       "       [79, 24, 64],\n",
       "       [57, 91, 81],\n",
       "       [13, 52,  0],\n",
       "       [ 5, 25, 10],\n",
       "       [33, 33, 36],\n",
       "       [13, 69, 95],\n",
       "       [11, 99, 89],\n",
       "       [94, 55, 84],\n",
       "       [72, 20, 14],\n",
       "       [18, 33, 15],\n",
       "       [13, 50, 95],\n",
       "       [25, 59,  5],\n",
       "       [90, 44, 78],\n",
       "       [92, 29, 62],\n",
       "       [35, 81, 16],\n",
       "       [95, 77, 35],\n",
       "       [65, 90, 34],\n",
       "       [27, 70, 44],\n",
       "       [56, 84, 15],\n",
       "       [41, 87,  7],\n",
       "       [56, 23, 50],\n",
       "       [86, 79, 45],\n",
       "       [85, 95, 75],\n",
       "       [75,  8, 52],\n",
       "       [22,  3, 23],\n",
       "       [47, 41, 44],\n",
       "       [82, 22,  5],\n",
       "       [ 9, 51, 34],\n",
       "       [40, 96, 63],\n",
       "       [67, 76, 52],\n",
       "       [33, 96, 87],\n",
       "       [15,  8, 85],\n",
       "       [92, 43, 79],\n",
       "       [81, 32, 47]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "array([[95, 22, 61],\n",
       "       [17, 19, 89],\n",
       "       [80, 93, 28],\n",
       "       [88, 39, 76],\n",
       "       [29, 78, 92],\n",
       "       [54,  4, 23],\n",
       "       [46, 77, 86],\n",
       "       [95, 23, 13],\n",
       "       [68, 88, 53],\n",
       "       [ 3, 72, 41],\n",
       "       [ 3,  9, 78],\n",
       "       [24, 94, 95],\n",
       "       [34, 94, 54],\n",
       "       [31, 72, 42],\n",
       "       [86, 97, 93],\n",
       "       [81, 52, 18],\n",
       "       [83, 74, 20],\n",
       "       [ 2, 42,  8],\n",
       "       [55, 92, 48],\n",
       "       [97, 26, 46],\n",
       "       [52, 58, 33],\n",
       "       [22,  6, 52],\n",
       "       [11, 34, 51],\n",
       "       [75, 50, 90],\n",
       "       [ 0, 84,  8],\n",
       "       [77, 50, 84],\n",
       "       [32,  7, 40],\n",
       "       [15, 83, 18],\n",
       "       [21,  2, 72],\n",
       "       [13, 78,  1],\n",
       "       [25, 66, 84],\n",
       "       [98, 78, 85],\n",
       "       [15, 38, 74],\n",
       "       [51, 85, 51],\n",
       "       [ 9,  7, 71],\n",
       "       [81, 58, 99],\n",
       "       [77, 92, 65],\n",
       "       [31, 31, 27],\n",
       "       [28, 37, 23],\n",
       "       [24, 88, 40],\n",
       "       [73, 15, 71],\n",
       "       [ 5,  4, 92],\n",
       "       [51, 26, 87],\n",
       "       [61, 42, 65],\n",
       "       [26, 22, 29],\n",
       "       [30, 21, 25],\n",
       "       [32, 88, 79],\n",
       "       [24, 51,  6],\n",
       "       [54, 89,  9],\n",
       "       [14, 33, 23]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import numpy as np\n",
    "a1 = np.random.randint(0,100,size=(50,3)) #随机生成6个班50个学生的成绩\n",
    "a2 = np.random.randint(0,100,size=(50,3))\n",
    "a3 = np.random.randint(0,100,size=(50,3))\n",
    "a4 = np.random.randint(0,100,size=(50,3))\n",
    "a5 = np.random.randint(0,100,size=(50,3))\n",
    "a6 = np.random.randint(0,100,size=(50,3))\n",
    "display(a1,a2,a3,a4,a5,a6)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "be5554cf",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[95, 81, 47],\n",
       "       [10, 51, 80],\n",
       "       [56, 33, 53],\n",
       "       [36, 74, 88],\n",
       "       [39, 79, 63],\n",
       "       [97, 63, 47],\n",
       "       [66, 25, 94],\n",
       "       [29, 29, 64],\n",
       "       [33, 25, 23],\n",
       "       [78, 35, 70],\n",
       "       [87, 37, 57],\n",
       "       [99, 18, 90],\n",
       "       [60, 69, 62],\n",
       "       [90, 76, 14],\n",
       "       [29,  2, 53],\n",
       "       [20, 36,  1],\n",
       "       [23, 42, 33],\n",
       "       [ 1, 18, 94],\n",
       "       [ 7, 53, 92],\n",
       "       [ 7, 77, 35],\n",
       "       [77, 57, 54],\n",
       "       [57, 63, 26],\n",
       "       [52, 35, 47],\n",
       "       [55, 67, 96],\n",
       "       [84, 80,  2],\n",
       "       [ 3, 63, 96],\n",
       "       [97, 72, 85],\n",
       "       [84, 57,  5],\n",
       "       [42, 52, 19],\n",
       "       [ 3,  8, 41],\n",
       "       [84, 32, 39],\n",
       "       [18, 56, 78],\n",
       "       [52, 32, 15],\n",
       "       [76, 34, 65],\n",
       "       [13, 83, 17],\n",
       "       [10, 76, 94],\n",
       "       [67, 54, 19],\n",
       "       [49, 32, 61],\n",
       "       [ 5, 87, 10],\n",
       "       [93, 83, 30],\n",
       "       [31, 17, 88],\n",
       "       [44, 55, 28],\n",
       "       [81,  0, 72],\n",
       "       [49, 78, 33],\n",
       "       [64, 38, 73],\n",
       "       [88, 79, 32],\n",
       "       [55, 76, 97],\n",
       "       [11, 88, 10],\n",
       "       [35, 38, 49],\n",
       "       [86, 47, 12],\n",
       "       [12, 77, 38],\n",
       "       [ 8, 42, 61],\n",
       "       [34, 16, 82],\n",
       "       [42, 98,  0],\n",
       "       [ 4, 11, 77],\n",
       "       [20, 72, 57],\n",
       "       [30, 13, 53],\n",
       "       [30,  1, 74],\n",
       "       [73, 85, 36],\n",
       "       [45, 85, 32],\n",
       "       [64, 75, 88],\n",
       "       [51, 63, 26],\n",
       "       [88, 55, 70],\n",
       "       [60, 86, 66],\n",
       "       [23, 57,  6],\n",
       "       [76,  3, 36],\n",
       "       [52, 19, 54],\n",
       "       [80, 50, 42],\n",
       "       [ 5, 57, 47],\n",
       "       [76, 25,  4],\n",
       "       [ 1, 99, 49],\n",
       "       [ 7, 44, 70],\n",
       "       [53, 83, 78],\n",
       "       [59, 59, 23],\n",
       "       [17, 29, 99],\n",
       "       [47, 61,  2],\n",
       "       [ 4, 74, 28],\n",
       "       [57,  8, 88],\n",
       "       [76, 42, 46],\n",
       "       [74, 96, 34],\n",
       "       [29, 31, 80],\n",
       "       [58, 82, 91],\n",
       "       [67, 99, 78],\n",
       "       [34,  7, 12],\n",
       "       [61, 36, 61],\n",
       "       [19, 70,  3],\n",
       "       [75, 91, 41],\n",
       "       [20, 22, 92],\n",
       "       [61,  3, 19],\n",
       "       [62, 87, 30],\n",
       "       [66, 82, 86],\n",
       "       [28, 53, 76],\n",
       "       [16, 54, 48],\n",
       "       [83, 52, 20],\n",
       "       [43,  4, 97],\n",
       "       [14,  1, 97],\n",
       "       [90, 77,  8],\n",
       "       [56, 95,  0],\n",
       "       [55, 30, 14],\n",
       "       [54, 89, 82],\n",
       "       [44, 56, 26],\n",
       "       [ 3, 40, 44],\n",
       "       [76, 24, 61],\n",
       "       [80, 77, 74],\n",
       "       [60, 64, 61],\n",
       "       [28, 93, 53],\n",
       "       [80, 60, 36],\n",
       "       [46, 92, 48],\n",
       "       [99,  4, 51],\n",
       "       [83, 33, 40],\n",
       "       [14, 35,  8],\n",
       "       [84, 74, 76],\n",
       "       [54, 59, 15],\n",
       "       [52, 58, 87],\n",
       "       [39, 32, 36],\n",
       "       [22, 71, 66],\n",
       "       [43, 26, 67],\n",
       "       [ 0, 46, 99],\n",
       "       [38, 75, 45],\n",
       "       [20, 85, 42],\n",
       "       [87, 84, 73],\n",
       "       [15, 76, 12],\n",
       "       [42, 14, 68],\n",
       "       [96, 82, 55],\n",
       "       [98, 95, 69],\n",
       "       [ 8, 37, 91],\n",
       "       [82, 35, 24],\n",
       "       [ 8, 99, 54],\n",
       "       [44, 93, 52],\n",
       "       [89, 74, 39],\n",
       "       [88, 30, 97],\n",
       "       [18, 25, 40],\n",
       "       [90, 94,  0],\n",
       "       [93, 48, 64],\n",
       "       [61, 86, 25],\n",
       "       [12, 69, 71],\n",
       "       [38,  2, 63],\n",
       "       [ 3, 30, 61],\n",
       "       [74, 38, 62],\n",
       "       [34, 63, 81],\n",
       "       [36, 78, 47],\n",
       "       [87, 30, 99],\n",
       "       [87, 58, 95],\n",
       "       [57, 24, 63],\n",
       "       [51, 90, 60],\n",
       "       [ 4, 62, 56],\n",
       "       [80,  3,  3],\n",
       "       [28, 54, 68],\n",
       "       [ 5, 48, 75],\n",
       "       [ 0, 22, 71],\n",
       "       [ 0, 19, 32],\n",
       "       [ 1, 91, 55],\n",
       "       [60, 16, 42],\n",
       "       [40, 85, 60],\n",
       "       [34, 53, 40],\n",
       "       [16,  4, 38],\n",
       "       [93, 66, 12],\n",
       "       [35, 79, 52],\n",
       "       [52, 15, 60],\n",
       "       [91, 20, 51],\n",
       "       [37, 68, 59],\n",
       "       [88, 79, 85],\n",
       "       [66, 63, 11],\n",
       "       [57, 94, 37],\n",
       "       [ 1,  0, 20],\n",
       "       [24, 53, 92],\n",
       "       [ 0, 68, 86],\n",
       "       [62, 13, 23],\n",
       "       [15, 87, 22],\n",
       "       [47, 33, 10],\n",
       "       [34, 15, 85],\n",
       "       [76,  2, 54],\n",
       "       [59, 61, 44],\n",
       "       [ 5, 19, 82],\n",
       "       [ 0,  1,  2],\n",
       "       [10, 13, 87],\n",
       "       [ 4, 88, 14],\n",
       "       [10, 21, 70],\n",
       "       [ 8, 26, 25],\n",
       "       [24, 52, 35],\n",
       "       [67, 21, 76],\n",
       "       [57, 36, 67],\n",
       "       [55, 89, 63],\n",
       "       [20, 72, 92],\n",
       "       [21, 82, 66],\n",
       "       [62, 94,  6],\n",
       "       [ 6,  8, 40],\n",
       "       [37, 62, 76],\n",
       "       [19, 32, 95],\n",
       "       [96, 99, 29],\n",
       "       [67, 68, 84],\n",
       "       [13, 12, 67],\n",
       "       [14, 15, 82],\n",
       "       [80,  9, 42],\n",
       "       [46, 95, 32],\n",
       "       [11, 75,  1],\n",
       "       [40, 70, 22],\n",
       "       [68, 95, 26],\n",
       "       [41, 21, 82],\n",
       "       [47, 55, 25],\n",
       "       [ 9, 14, 63],\n",
       "       [27, 64, 73],\n",
       "       [79, 81, 25],\n",
       "       [35, 92, 95],\n",
       "       [21, 78,  8],\n",
       "       [20, 48, 69],\n",
       "       [64, 95, 80],\n",
       "       [94, 62, 80],\n",
       "       [19, 67, 15],\n",
       "       [57, 39, 40],\n",
       "       [73, 72, 79],\n",
       "       [96, 31, 10],\n",
       "       [59,  1, 51],\n",
       "       [47, 90, 98],\n",
       "       [29, 50, 99],\n",
       "       [46, 49, 34],\n",
       "       [79, 24, 64],\n",
       "       [57, 91, 81],\n",
       "       [13, 52,  0],\n",
       "       [ 5, 25, 10],\n",
       "       [33, 33, 36],\n",
       "       [13, 69, 95],\n",
       "       [11, 99, 89],\n",
       "       [94, 55, 84],\n",
       "       [72, 20, 14],\n",
       "       [18, 33, 15],\n",
       "       [13, 50, 95],\n",
       "       [25, 59,  5],\n",
       "       [90, 44, 78],\n",
       "       [92, 29, 62],\n",
       "       [35, 81, 16],\n",
       "       [95, 77, 35],\n",
       "       [65, 90, 34],\n",
       "       [27, 70, 44],\n",
       "       [56, 84, 15],\n",
       "       [41, 87,  7],\n",
       "       [56, 23, 50],\n",
       "       [86, 79, 45],\n",
       "       [85, 95, 75],\n",
       "       [75,  8, 52],\n",
       "       [22,  3, 23],\n",
       "       [47, 41, 44],\n",
       "       [82, 22,  5],\n",
       "       [ 9, 51, 34],\n",
       "       [40, 96, 63],\n",
       "       [67, 76, 52],\n",
       "       [33, 96, 87],\n",
       "       [15,  8, 85],\n",
       "       [92, 43, 79],\n",
       "       [81, 32, 47],\n",
       "       [95, 22, 61],\n",
       "       [17, 19, 89],\n",
       "       [80, 93, 28],\n",
       "       [88, 39, 76],\n",
       "       [29, 78, 92],\n",
       "       [54,  4, 23],\n",
       "       [46, 77, 86],\n",
       "       [95, 23, 13],\n",
       "       [68, 88, 53],\n",
       "       [ 3, 72, 41],\n",
       "       [ 3,  9, 78],\n",
       "       [24, 94, 95],\n",
       "       [34, 94, 54],\n",
       "       [31, 72, 42],\n",
       "       [86, 97, 93],\n",
       "       [81, 52, 18],\n",
       "       [83, 74, 20],\n",
       "       [ 2, 42,  8],\n",
       "       [55, 92, 48],\n",
       "       [97, 26, 46],\n",
       "       [52, 58, 33],\n",
       "       [22,  6, 52],\n",
       "       [11, 34, 51],\n",
       "       [75, 50, 90],\n",
       "       [ 0, 84,  8],\n",
       "       [77, 50, 84],\n",
       "       [32,  7, 40],\n",
       "       [15, 83, 18],\n",
       "       [21,  2, 72],\n",
       "       [13, 78,  1],\n",
       "       [25, 66, 84],\n",
       "       [98, 78, 85],\n",
       "       [15, 38, 74],\n",
       "       [51, 85, 51],\n",
       "       [ 9,  7, 71],\n",
       "       [81, 58, 99],\n",
       "       [77, 92, 65],\n",
       "       [31, 31, 27],\n",
       "       [28, 37, 23],\n",
       "       [24, 88, 40],\n",
       "       [73, 15, 71],\n",
       "       [ 5,  4, 92],\n",
       "       [51, 26, 87],\n",
       "       [61, 42, 65],\n",
       "       [26, 22, 29],\n",
       "       [30, 21, 25],\n",
       "       [32, 88, 79],\n",
       "       [24, 51,  6],\n",
       "       [54, 89,  9],\n",
       "       [14, 33, 23]])"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 将6个班学生成绩合并成一个二维数组\n",
    "score = np.concatenate([a1,a2,a3,a4,a5,a6])\n",
    "score"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "id": "51d865d2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(300, 3)"
      ]
     },
     "execution_count": 63,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "score.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "id": "ba3c5894",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1],\n",
       "       [0],\n",
       "       [0],\n",
       "       [1],\n",
       "       [0],\n",
       "       [0],\n",
       "       [0],\n",
       "       [1],\n",
       "       [1],\n",
       "       [1],\n",
       "       [0],\n",
       "       [1],\n",
       "       [0],\n",
       "       [0],\n",
       "       [0],\n",
       "       [1],\n",
       "       [1],\n",
       "       [1],\n",
       "       [0],\n",
       "       [1],\n",
       "       [1],\n",
       "       [0],\n",
       "       [0],\n",
       "       [1],\n",
       "       [0],\n",
       "       [0],\n",
       "       [1],\n",
       "       [0],\n",
       "       [1],\n",
       "       [1],\n",
       "       [0],\n",
       "       [1],\n",
       "       [0],\n",
       "       [1],\n",
       "       [0],\n",
       "       [1],\n",
       "       [1],\n",
       "       [0],\n",
       "       [1],\n",
       "       [1],\n",
       "       [1],\n",
       "       [0],\n",
       "       [0],\n",
       "       [0],\n",
       "       [1],\n",
       "       [0],\n",
       "       [0],\n",
       "       [0],\n",
       "       [1],\n",
       "       [0],\n",
       "       [0],\n",
       "       [1],\n",
       "       [0],\n",
       "       [1],\n",
       "       [1],\n",
       "       [0],\n",
       "       [0],\n",
       "       [0],\n",
       "       [0],\n",
       "       [1],\n",
       "       [1],\n",
       "       [1],\n",
       "       [1],\n",
       "       [0],\n",
       "       [1],\n",
       "       [0],\n",
       "       [1],\n",
       "       [0],\n",
       "       [0],\n",
       "       [1],\n",
       "       [1],\n",
       "       [1],\n",
       "       [1],\n",
       "       [0],\n",
       "       [0],\n",
       "       [0],\n",
       "       [1],\n",
       "       [0],\n",
       "       [1],\n",
       "       [0],\n",
       "       [0],\n",
       "       [0],\n",
       "       [0],\n",
       "       [0],\n",
       "       [0],\n",
       "       [0],\n",
       "       [0],\n",
       "       [1],\n",
       "       [1],\n",
       "       [0],\n",
       "       [1],\n",
       "       [1],\n",
       "       [0],\n",
       "       [0],\n",
       "       [1],\n",
       "       [0],\n",
       "       [0],\n",
       "       [1],\n",
       "       [0],\n",
       "       [1],\n",
       "       [0],\n",
       "       [0],\n",
       "       [1],\n",
       "       [1],\n",
       "       [1],\n",
       "       [1],\n",
       "       [1],\n",
       "       [0],\n",
       "       [0],\n",
       "       [1],\n",
       "       [0],\n",
       "       [1],\n",
       "       [1],\n",
       "       [1],\n",
       "       [1],\n",
       "       [0],\n",
       "       [1],\n",
       "       [1],\n",
       "       [1],\n",
       "       [1],\n",
       "       [0],\n",
       "       [0],\n",
       "       [1],\n",
       "       [0],\n",
       "       [0],\n",
       "       [0],\n",
       "       [0],\n",
       "       [0],\n",
       "       [0],\n",
       "       [0],\n",
       "       [0],\n",
       "       [0],\n",
       "       [0],\n",
       "       [1],\n",
       "       [0],\n",
       "       [0],\n",
       "       [1],\n",
       "       [1],\n",
       "       [0],\n",
       "       [1],\n",
       "       [1],\n",
       "       [0],\n",
       "       [1],\n",
       "       [0],\n",
       "       [1],\n",
       "       [0],\n",
       "       [1],\n",
       "       [0],\n",
       "       [1],\n",
       "       [1],\n",
       "       [1],\n",
       "       [1],\n",
       "       [0],\n",
       "       [0],\n",
       "       [1],\n",
       "       [0],\n",
       "       [0],\n",
       "       [0],\n",
       "       [0],\n",
       "       [1],\n",
       "       [1],\n",
       "       [1],\n",
       "       [0],\n",
       "       [0],\n",
       "       [1],\n",
       "       [1],\n",
       "       [1],\n",
       "       [1],\n",
       "       [0],\n",
       "       [1],\n",
       "       [0],\n",
       "       [1],\n",
       "       [0],\n",
       "       [0],\n",
       "       [1],\n",
       "       [1],\n",
       "       [1],\n",
       "       [1],\n",
       "       [0],\n",
       "       [0],\n",
       "       [0],\n",
       "       [1],\n",
       "       [0],\n",
       "       [0],\n",
       "       [1],\n",
       "       [1],\n",
       "       [0],\n",
       "       [1],\n",
       "       [1],\n",
       "       [1],\n",
       "       [1],\n",
       "       [1],\n",
       "       [1],\n",
       "       [1],\n",
       "       [1],\n",
       "       [0],\n",
       "       [1],\n",
       "       [1],\n",
       "       [0],\n",
       "       [0],\n",
       "       [0],\n",
       "       [1],\n",
       "       [1],\n",
       "       [1],\n",
       "       [1],\n",
       "       [0],\n",
       "       [1],\n",
       "       [1],\n",
       "       [0],\n",
       "       [1],\n",
       "       [1],\n",
       "       [1],\n",
       "       [1],\n",
       "       [1],\n",
       "       [1],\n",
       "       [0],\n",
       "       [0],\n",
       "       [0],\n",
       "       [1],\n",
       "       [1],\n",
       "       [0],\n",
       "       [1],\n",
       "       [0],\n",
       "       [1],\n",
       "       [0],\n",
       "       [0],\n",
       "       [1],\n",
       "       [1],\n",
       "       [0],\n",
       "       [0],\n",
       "       [0],\n",
       "       [1],\n",
       "       [0],\n",
       "       [1],\n",
       "       [1],\n",
       "       [1],\n",
       "       [0],\n",
       "       [1],\n",
       "       [1],\n",
       "       [1],\n",
       "       [0],\n",
       "       [1],\n",
       "       [1],\n",
       "       [1],\n",
       "       [1],\n",
       "       [0],\n",
       "       [0],\n",
       "       [0],\n",
       "       [0],\n",
       "       [1],\n",
       "       [0],\n",
       "       [1],\n",
       "       [1],\n",
       "       [1],\n",
       "       [1],\n",
       "       [0],\n",
       "       [1],\n",
       "       [1],\n",
       "       [1],\n",
       "       [1],\n",
       "       [0],\n",
       "       [1],\n",
       "       [0],\n",
       "       [0],\n",
       "       [1],\n",
       "       [0],\n",
       "       [0],\n",
       "       [1],\n",
       "       [1],\n",
       "       [0],\n",
       "       [1],\n",
       "       [0],\n",
       "       [0],\n",
       "       [0],\n",
       "       [1],\n",
       "       [0],\n",
       "       [1],\n",
       "       [0],\n",
       "       [0],\n",
       "       [0],\n",
       "       [1],\n",
       "       [1],\n",
       "       [1],\n",
       "       [0],\n",
       "       [0],\n",
       "       [0],\n",
       "       [0],\n",
       "       [0],\n",
       "       [1],\n",
       "       [1],\n",
       "       [1],\n",
       "       [1],\n",
       "       [0],\n",
       "       [0],\n",
       "       [1],\n",
       "       [0],\n",
       "       [0],\n",
       "       [0],\n",
       "       [0],\n",
       "       [1]])"
      ]
     },
     "execution_count": 64,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sex = np.random.randint(0,2,size = (300,1))\n",
    "sex"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "id": "821dee29",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[95, 81, 47,  1],\n",
       "       [10, 51, 80,  0],\n",
       "       [56, 33, 53,  0],\n",
       "       ...,\n",
       "       [24, 51,  6,  0],\n",
       "       [54, 89,  9,  0],\n",
       "       [14, 33, 23,  1]])"
      ]
     },
     "execution_count": 66,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data = np.concatenate([score,sex],axis = 1)\n",
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "id": "eb8679a5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([False,  True,  True, False,  True,  True,  True, False, False,\n",
       "       False,  True, False,  True,  True,  True, False, False, False,\n",
       "        True, False, False,  True,  True, False,  True,  True, False,\n",
       "        True, False, False,  True, False,  True, False,  True, False,\n",
       "       False,  True, False, False, False,  True,  True,  True, False,\n",
       "        True,  True,  True, False,  True,  True, False,  True, False,\n",
       "       False,  True,  True,  True,  True, False, False, False, False,\n",
       "        True, False,  True, False,  True,  True, False, False, False,\n",
       "       False,  True,  True,  True, False,  True, False,  True,  True,\n",
       "        True,  True,  True,  True,  True,  True, False, False,  True,\n",
       "       False, False,  True,  True, False,  True,  True, False,  True,\n",
       "       False,  True,  True, False, False, False, False, False,  True,\n",
       "        True, False,  True, False, False, False, False,  True, False,\n",
       "       False, False, False,  True,  True, False,  True,  True,  True,\n",
       "        True,  True,  True,  True,  True,  True,  True, False,  True,\n",
       "        True, False, False,  True, False, False,  True, False,  True,\n",
       "       False,  True, False,  True, False, False, False, False,  True,\n",
       "        True, False,  True,  True,  True,  True, False, False, False,\n",
       "        True,  True, False, False, False, False,  True, False,  True,\n",
       "       False,  True,  True, False, False, False, False,  True,  True,\n",
       "        True, False,  True,  True, False, False,  True, False, False,\n",
       "       False, False, False, False, False, False,  True, False, False,\n",
       "        True,  True,  True, False, False, False, False,  True, False,\n",
       "       False,  True, False, False, False, False, False, False,  True,\n",
       "        True,  True, False, False,  True, False,  True, False,  True,\n",
       "        True, False, False,  True,  True,  True, False,  True, False,\n",
       "       False, False,  True, False, False, False,  True, False, False,\n",
       "       False, False,  True,  True,  True,  True, False,  True, False,\n",
       "       False, False, False,  True, False, False, False, False,  True,\n",
       "       False,  True,  True, False,  True,  True, False, False,  True,\n",
       "       False,  True,  True,  True, False,  True, False,  True,  True,\n",
       "        True, False, False, False,  True,  True,  True,  True,  True,\n",
       "       False, False, False, False,  True,  True, False,  True,  True,\n",
       "        True,  True, False])"
      ]
     },
     "execution_count": 68,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cond = data[:,3] == 0\n",
    "cond"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "id": "658a4fd5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([3, 0, 0, 0])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "array([99, 99, 99,  0])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "array([47.93835616, 51.66438356, 49.20547945,  0.        ])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "array([50. , 52.5, 51. ,  0. ])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "array([28.77956434, 29.36176747, 27.60308644,  0.        ])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "score_min = data[cond].min(axis = 0)\n",
    "score_max = data[cond].max(axis = 0)\n",
    "score_mean = data[cond].mean(axis = 0)\n",
    "score_median = np.median(data[cond],axis = 0)\n",
    "score_std = data[cond].std(axis = 0)\n",
    "display(score_min,score_max,score_mean,score_median,score_std)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d33824ae",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "110d1516",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6d5ca3d4",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3729827e",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.6"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
